package business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

import vo.SourceCategory;
import vo.User;
import business.SourceCategoryService;
import dao.SourceCategoryDAO;

public class SourceCategoryServiceImpl implements SourceCategoryService {

	private SourceCategoryDAO sourceCategoryDao;

	public List<SourceCategory> getAllSourceCategories() {
		return sourceCategoryDao.findAll();
	}

	//通过名称查找分组
	public List<SourceCategory> getByName(String name) {
		return sourceCategoryDao.findByName(name);
	}

	public List<SourceCategory> getAllSourceCategories(int start,int pageSize) {
		return sourceCategoryDao.findAll(start,pageSize);
	}
	public SourceCategory getByNameSourceId(String name,long sourceId) {
		return sourceCategoryDao.findByNameSourceId(name,sourceId);
	}
	public long getTotalCount() {
		return sourceCategoryDao.findTotalCount();
	}

	@Required
	public void setSourceCategoryDao(SourceCategoryDAO sourceCategoryDao) {
		this.sourceCategoryDao = sourceCategoryDao;
	}

	@Transactional
	public void addSourceCategory(String name) {
		SourceCategory e = new SourceCategory();
		e.setName(name);
		sourceCategoryDao.create(e);
	}

	@Transactional
	public void addSourceCategory(SourceCategory sourceCategory) {
		sourceCategoryDao.create(sourceCategory);
	}

	@Transactional
	public SourceCategory getById(long id) {
		return sourceCategoryDao.getById(id);
	}

	@Transactional
	public void update(SourceCategory sc) {
		sourceCategoryDao.update(sc);
	}

	@Transactional
	public void delete(SourceCategory sc) {
		sourceCategoryDao.delete(sc);
	}

}